/*
 * @Author: Tendo 
 * @Date: 2021-09-29 19:25:30 
 * @param {string} s
 * @return {boolean}
 */

var isValid = function(s) {
    const stack = [];
    for (let i = 0; i < s.length; i++) {
        let c = s[i];
        switch (c) {
            case '(':
                stack.push(')');
                break;
            case '[':
                stack.push(']');
                break;
            case '{':
                stack.push('}');
                break;
            default:  // 如果没有与表达式相同的值，则执行该代码
                if (c !== stack.pop()) {
                    return false;
                }
        }
    }
    return stack.length === 0;
};
